solving repeated exponentiation